package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.client.ItemFeignClient;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author tongatong
 * @name ItemController
 * @description
 * @date 2021/9/15
 * @time 9:26
 */
@Controller
public class ItemController {
    @Resource
    private ItemFeignClient itemFeignClient;

    @RequestMapping("{skuId}.html")
    public String getItem(@PathVariable Long skuId, Model model) {
        Result<Map<String, Object>> item = itemFeignClient.getItem(skuId);
        model.addAllAttributes(item.getData());

        return "item/index";
    }
}
